<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>告警处理日志</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0"> 
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<jsp:include page="../resource.jsp"></jsp:include>
	<style type="text/css">
	    #authority table, caption, tbody, tfoot, thead, tr, th, td{
	        vertical-align: middle;
	    }
	</style>
	<script type="text/javascript">
	$(document).ready(function() {
		var h = '80%';
 		if($.browser.msie && ($.browser.version == 8.0 || $.browser.version == 9.0)){
 	    	 h = $(self.parent.parent.frames['mainFrame']).height()-157; 
 	    }
        $("#alarmLog").omGrid({
        	dataSource : 'alarmLog!findAll.do',
            height : h,
            limit : 20,
            showIndex : true,
            colModel : [ 
                         {header : '设备名称', name : 'device', width : 100, align : 'center',renderer : function(value){
                        	 if(value == null) {
                        		 return '';
                        	 }else{
                        		 return value.name;
                        	 }
                         }},
                         {header : '组织', name : 'device', width : 100, align : 'center',renderer : function(value){
                        	 if(value == null) {
                        		 return '';
                        	 }else{
                        		 return value.organization.name;
                        	 }
                         }},
                         {header : '告警时间', name : 'datetime', width : 140, align : 'center'},
                         {header : '告警分类', name : 'alarmClass', width : 70, align : 'center',renderer : function(value){
                        	 if(value == null) {
                        		 return '';
                        	 }else{
                        		 return value.name;
                        	 }
                         }},
                         {header : '告警级别', name : 'alarmClass', width : 70, align : 'center',renderer : function(value){
                        	 if(value == null) {
                        		 return '';
                        	 }else{
                        		 return value.level;
                        	 }
                         }},
                         {header : '告警内容', name : 'content', width : 200, align : 'left'},
                         {header : '处理状态', name : 'status', width : 70, align : 'center',renderer:function(value){
                             if(value == '0'){
                            	 return '处理完毕';
                             }else if(value == '1'){
                            	 return '未处理';
                             }else if(value == '2'){
                            	 return '已确认';
                             }else if(value == '3'){
                            	 return '已派修';
                             }else if(value == '-1') {
                            	 return '已清除';
                             }
                             return '未处理';
                         }}, 
                         {header : '处理人', name : 'userName', width : 90, align : 'center'},
                         {header : '处理时间', name : 'confirmDatetime', width : 140, align : 'center'},
                         {header : '路由表', name : 'router', width : 90, align : 'center'}] 
        });
        
        $("#alarmLogConfirm").click(function(){
        	var selects = $("#alarmLog").omGrid("getSelections",true);
        	if(selects.length <= 0){
        		$.omMessageBox.alert({content:'请您选择需要处理的记录'});
        		return;
        	}
        	$.omMessageBox.confirm({
                title:'确认记录',
                content:'您确定处理该记录吗？',
                onClose:function(result){
               	 if(result){
               		 $.ajax({
               			 url : 'alarmLog!confirm.do',
               			 data : {alarmLogId:selects[0].id},
               			 success : function(data){
               				 if(data == '1'){
               					 $.omMessageTip.show({timeout : 2000,content : '确认成功！'});
               					 $("#alarmLog").omGrid("reload");
               				 }else{
               					 $.omMessageTip.show({timeout : 2000,content : '确认失败！'});
               				 }
               			 }
               		 });
               	 }
                }
            });
        });
        
        $("#alarmLogDeal").click(function(){
        	var selects = $("#alarmLog").omGrid("getSelections",true);
        	if(selects.length <= 0){
        		$.omMessageBox.alert({content:'请您选择需要派修的记录'});
        		return;
        	}
        	$.omMessageBox.confirm({
                title:'处理记录',
                content:'您确定处理该记录吗？',
                onClose:function(result){
               	 if(result){
               		 $.ajax({
               			 url : 'alarmLog!deal.do',
               			 data : {alarmLogId:selects[0].id},
               			 success : function(data){
               				 if(data == '1'){
               					 $.omMessageTip.show({timeout : 2000,content : '派修成功！'});
               					 $("#alarmLog").omGrid("reload");
               				 }else{
               					 $.omMessageTip.show({timeout : 2000,content : '派修失败！'});
               				 }
               			 }
               		 });
               	 }
                }
            });
        });
        
        $("#alarmLogClosed").click(function(){
        	var selects = $("#alarmLog").omGrid("getSelections",true);
        	if(selects.length <= 0){
        		$.omMessageBox.alert({content:'请您选择需要清除的记录'});
        		return;
        	}
        	$.omMessageBox.confirm({
                title:'确认',
                content:'您确定处理该记录吗？',
                onClose:function(result){
               	 if(result){
               		 $.ajax({
               			 url : 'alarmLog!close.do',
               			 data : {alarmLogId:selects[0].id},
               			 success : function(data){
               				 if(data == '1'){
               					 $.omMessageTip.show({timeout : 2000,content : '清除成功！'});
               					 $("#alarmLog").omGrid("reload");
               				 }else{
               					 $.omMessageTip.show({timeout : 2000,content : '清除失败！'});
               				 }
               			 }
               		 });
               	 }
                }
            });
        });
        
        	$("#alarmLongSerach").click(function() {
        		var deviceId = $("#deviceId").val();
        		var alarmClassType = $("#alarmClassType").val();
        		var alarmClassLevel = $("#alarmClassLevel").val();
        		var alarmLogStatus = $("#alarmLogStatus").val();
        		var alarmLogTime = $("#alarmLogDateTime").val();
                $("#alarmLog").omGrid('setData','alarmLog!findAll.do?deviceId='+deviceId+'&alarmClassType='+alarmClassType+'&alarmClassLevel='+alarmClassLevel+'&alarmLogStatus='+alarmLogStatus+'&alarmLogTime='+alarmLogTime);
                return false;//返回false,阻止浏览器默认行为
            });
        	$("#resetBtn").click(function() {
        		$('#deviceName').val('点击右侧菜单');
        		$('#deviceId').val('');
        	});
        	
		var tabId = self.parent.parent.frames['mainFrame'].$('#tabs').omTabs('getActivated');
		var s = "<script>function function_"+tabId+"(nodeData){$('#deviceName').val(nodeData.text);"+
		"$('#deviceId').val(nodeData.id);}<\/script>";
		$("#alarmLog").after(s);
    });
	</script>  
  </head>
  
  <body>
  	<div class="select_table">
		<table   cellpadding="0" cellspacing="0" class="layout"  border="0">
	          <tr>
	            <td width="11%" align="right">区域/组织/设备：</td>
	            <td width="9%">
	            	<input name="alarmLog.device.name" id="deviceName" type="text" readonly="readonly" value="点击右侧菜单选择" size="14"/>
	            	<input name="alarmLog.device.guid" id="deviceId" type="hidden"/>
	            </td>
	            
	            <td width="8%" align="right">告警分类：</td>
	            <td width="8%"><select name="alarmLog.alarmClass.type" id="alarmClassType" >
                  	<option value="">全部</option>
                  	<option value="1">软件告警</option>
                  	<option value="2">硬件告警</option>
                  	<option value="3">通信告警</option>
                  </select></td>
	            <td width="8%" align="right">告警等级：</td>
	            <td width="5%"><select name="alarmLog.alarmClass.level" id="alarmClassLevel">
                 	<option value="0">全部</option>
                 	<option value="1" selected="selected">1</option>
                 	<option value="2">2</option>
                 	<option value="3">3</option>
                 	<option value="4">4</option>
                 	<option value="5">5</option>
                 </select></td>
	            <td width="5%" align="right">状态：</td>
	            <td width="8%"><select name="alarmLog.status" id="alarmLogStatus">
                 	<option value="0">全部</option>
                 	<option value="1" selected="selected">未处理</option>
                 	<option value="2">已确认</option>
                 	<option value="3">已派修</option>
                 	<option value="-1">已清除</option>
                 	<option value="0">处理完毕</option>
                 </select></td>
                 <td width="5%" align="right">时间：</td>
	            <td width="8%"><select name="alarmLog.dateTime" id="alarmLogDateTime">
                 	<option value="9">全部</option>
                 	<option value="0" selected="selected">一周内</option>
                 	<option value="1" >一周前</option>
                 </select></td>
	            <td align="left">
	            	<button class="button_u" id="alarmLongSerach" onmousemove="this.className='button_f'" onmousedown="this.className='button_d'" onmouseout="this.className='button_u'">查询</button>
	            	<button class="button_u" id="resetBtn" onmousemove="this.className='button_f'" onmousedown="this.className='button_d'" onmouseout="this.className='button_u'">重置</button>
	            </td>
	          </tr>
	    </table>
	</div>
    <div class="toolbar mar">
		<a href="#" class="rbutton" id="alarmLogConfirm"><span><img src="../images/btn_u.gif" width="14" height="14" /><ins>确认</ins></span></a>
		<a  class="line"></A>
		<a href="#" class="rbutton" id="alarmLogDeal"><span><img src="../images/btn_u.gif" width="14" height="14" /><ins>派修</ins></span></a>
		<a  class="line"></A>
		<a href="#" class="rbutton" id="alarmLogClosed"><span><img src="../images/btn_u.gif" width="14" height="14" /><ins>清除</ins></span></a>
	</div>
    <table id="alarmLog"></table>
  </body>
</html>
